package com.basker.pisces.trace.event;

import org.springframework.context.ApplicationEvent;

import com.basker.pisces.trace.Span;

/**
 * Span的事件抽象类
 *
 * @author hangwen
 */
public abstract class SpanEvent extends ApplicationEvent {

    private static final long serialVersionUID = -2619416124552030575L;

    protected Span span;

    public SpanEvent(Object source, Span span) {
        super(source);
        this.span = span;
    }

    public Span getSpan() {
        return span;
    }

    /**
     * Span创建事件
     *
     * @author hangwen
     */
    public static class CreateEvent extends SpanEvent {

        private static final long serialVersionUID = 4980931962945629682L;

        public CreateEvent(Object source, Span span) {
            super(source, span);
        }
    }

    /**
     * Span销毁事件
     *
     * @author hangwen
     */
    public static class DestoryEvent extends SpanEvent {

        private static final long serialVersionUID = 4980931962945629682L;

        public DestoryEvent(Object source, Span span) {
            super(source, span);
        }
    }

}
